﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Domain.Repositories;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;

namespace JXT.PrimaryKey.Batman.Domain.UserSystem.Repositories
{
    public interface IUserRepository : IReadRepository<User, int>,
        IWriteRepository<User, int>,
        ISpecificationRepository<User>
    {
        UserDetail GetDetail(int userId);

        UserStatus GetStatus(int userId);

        /// <summary>
        /// 缓存中找不到LoginStatus 需要根据Token从数据库中获取
        /// </summary>
        /// <param name="token">令牌</param>
        /// <returns>LoginStatus对象</returns>
        LoginStatus GetLoginStatus(string token);

        IEnumerable<LoginStatus> GetLoginStatusList(int userId);

        void AddDetail(UserDetail detail);

        void AddStatus(UserStatus status);

        void AddLoginStatus(LoginStatus loginStatus);

        void UpdateDetail(UserDetail detail);

        void UpdateStatus(UserStatus status);

        void UpdateLoginStatus(LoginStatus loginStatus);

        void DeleteDetail(int userId);

        void DeleteStatus(int userId);

        void DeleteLoginStatus(string token);

        void DeleteAllLoginStatus(int userId);

        int[] GetRoleIdArray(int userId);

        void SetAuthority(int userId, Authority[] authorityArray);

        void AddRoles(int userId, int[] roleIdArray);

        void DeleteRoles(int userId, int[] roleIdArray);

        /// <summary>
        /// 添加微博用户和本地用户的关联
        /// </summary>
        /// <param name="userId">本地用户Id</param>
        /// <param name="blogUserId">微博用户id(或者name)</param>
        /// <param name="mark">标示是哪一方的微博用户</param>
        void AddOAuthUserBinding(OAuthUserBinding userBinding);

        /// <summary>
        /// 根据微博用户id，和微博Id获取存储在本地的用户id
        /// </summary>
        /// <param name="blogUserId">微博用户ID</param>
        /// <param name="mark">标示哪一方</param>
        /// <returns>MicroBlogUser对象</returns>
        OAuthUserBinding GetOAuthUserBindingSingle(string userIdentity, int authId);

        OAuthUserBinding GetOAuthUserBindingSingle(ISpecification<OAuthUserBinding> specification);

        void DeleteOAuthUserBinding(int id);

        IEnumerable<OAuthUserBinding> GetOAuthUserBindingList(ISpecification<OAuthUserBinding> specification);
    }
}
